//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class HslEffect : Effect
    {
        private double hue;
        private double lum;

        private double sat;

        public double Hue
        {
            get { return hue; }
            set { hue = value; }
        }

        public double Saturation
        {
            get { return sat; }
            set { sat = value; }
        }

        public double Luminance
        {
            get { return lum; }
            set { lum = value; }
        }

        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("hsl"))
            {
                Hue = SerializationHelper.GetOptionalPositiveFixedAngle(c, "hue", 0);
                Saturation = SerializationHelper.GetOptionalPercent(c, "sat", 0);
                Luminance = SerializationHelper.GetOptionalPercent(c, "lum", 0);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("hsl"))
            {
                SerializationHelper.SetOptionalPositiveFixedAngle(c, "hue", Hue, 0);
                SerializationHelper.SetOptionalPercent(c, "sat", Saturation, 0);
                SerializationHelper.SetOptionalPercent(c, "lum", Luminance, 0);
            }
        }
    }
}